package com.ias.agdis_r.fragment.task;

import android.content.Intent;
import android.os.Bundle;
//import android.support.v4.app.Fragment;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import com.ias.agdis_r.R;
import com.ias.agdis_r.activity.task.NFTaskInfoActivity;
import com.ias.agdis_r.adapter.NFTaskListViewAdapter;
import com.ias.agdis_r.manager.DataManager;
import com.ias.agdis_r.module.MessageModel;

/**
 * Created by guoxr on 2015/9/21.
 */
public class NFTaskHisListFragment extends Fragment {
    private ListView mListView;
    private NFTaskListViewAdapter mAdapter;
    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.task_nflight_tab_02, container, false);
        checkInfo();
        mListView = (ListView) view.findViewById(R.id.ListView);
        mAdapter = new NFTaskListViewAdapter(getActivity(), true, false);
        mListView.setAdapter(mAdapter);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                    long arg3) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(getActivity(), NFTaskInfoActivity.class);
                intent.putExtra(MessageModel.TNB, mAdapter.getTNB(arg2));
                intent.putExtra("ishis", true);
                startActivity(intent);
            }
        });
        return view;
    }
    private void checkInfo() {
        TextView noInfo = (TextView) view.findViewById(R.id.tv_noInfo);
        DataManager dm = DataManager.getInstance();
        if (0 == dm.getNFTaskHistroyWorkList().size()) {
            noInfo.setVisibility(View.VISIBLE);
        } else {
            noInfo.setVisibility(View.GONE);
        }
    }
}
